/*
 *  shake 抖动效果
 */
  
 // shake 样式
import "@/styles/shake.scss";
import type { Directive, DirectiveBinding } from "vue";
interface ElType extends HTMLElement {
  __handleInput__: () => any;
}
// 根据el获取input

  const shake: Directive = {
    mounted(el: ElType, binding: DirectiveBinding) { 
          
        console.log(el,"抖动。。。。");

        setInterval(()=>{
            // el.style.animation = "shake 0.82s cubic-bezier(.36,.07,.19,.97) both";
            el.style.animation = "shake .9s cubic-bezier(0.42,0,0.58,1) both";
            el.__handleInput__=function(){
                el.style.animation =""
            }
            el.addEventListener('animationend',el.__handleInput__) 
        },800)
    },
 
    beforeUnmount(el: ElType) {
       // 解除绑定的时候去除事件 
      el.removeEventListener("animationend",el.__handleInput__);
    }
  };
  
 
  
  export default shake;